Skip to content

使用 broot 替代 tree

标签
命令行/终端
命令行/broot
命令行/tree
操作系统/Unix
操作系统/Linux
Linux/命令行
Linux
命令行/brew
操作系统/macOS
开源/软件/zsh
开源/软件/bash
开源/软件/fish
开源/软件/broot
字数
570 字
阅读时间
3 分钟

之前有幸看到 ibraheemdev/modern-unix: A collection of modern/faster/saner alternatives to common unix commands. GitHub Repo 介绍了一些替代默认 UNIX 命令的现代 CLI 工具来完成很多工作。

其中就有 broot 命令可以替代 tree 并且得到更好的目录观察和管理的效果。

可以通过 brew 来安装:

shell
brew install broot

其他安装的方法可以参见作者的文档 Install broot - Broot (dystroy.org)

安装之后在终端中就可以使用了:

shell
 broot

Broot should be launched using a shell function.
This function most notably makes it possible to cd from inside broot
(see https://dystroy.org/broot/install-br/ for explanations).

Can I install it now? [Y/n]
Y
Writing br shell function in /Users/neko/Library/Application Support/org.dystroy.broot/launcher/bash/1.
Creating link from /Users/neko/.config/broot/launcher/bash/br to /Users/neko/Library/Application Support/org.dystroy.broot/launcher/bash/1.
/Users/neko/.bashrc successfully patched, you can make the function immediately available with source /Users/neko/.bashrc
/Users/neko/.bash_profile successfully patched, you can make the function immediately available with source /Users/neko/.bash_profile
/Users/neko/.zshrc successfully patched, you can make the function immediately available with exec zsh
/Users/neko/.zshrc already patched, no change made.
Writing br shell function in /Users/neko/Library/Application Support/org.dystroy.broot/launcher/fish/br.fish.
Creating link from /Users/neko/.config/fish/functions/br.fish to /Users/neko/Library/Application Support/org.dystroy.broot/launcher/fish/br.fish.

The br function has been successfully installed.
You may have to restart your shell or source your shell init files.
Afterwards, you should start broot with br in order to use its full power.

首次使用的时候会请求安装 br 函数来方便 broot 在交互式导航的时候能够来回导航并且 cd 到不同的目录下进行导航和操作,在看到

Can I install it now? [Y/n]

的时候就可以输入 Y 来接受安装请求,就像上面那样,在接受安装之后,它将会

如果你使用 bash

  1. $XDG_CONFIG_HOME/org.dystroy.broot/launcher/bash/1 写入 Bash 使用的 Shell 函数
  2. $XDG_CONFIG_HOME/org.dystroy.broot/launcher/bash/1 软链接到 $HOME/.config/broot/launcher/bash/br
  3. 修改 $HOME/.bashrc 新增一条 br 函数相关的引用
  4. 修改 $HOME/.bash_profile 新增一条 br 函数相关的引用
shell
source /Users/neko/.config/broot/launcher/bash/br

如果你使用 zsh

  1. 修改 $HOME/.zshrc 并新增一条 br 函数相关的引用
shell
source /Users/neko/.config/broot/launcher/bash/br

如果你使用 fish

  1. $XDG_CONFIG_HOME/org.dystroy.broot/launcher/fish/br.fish 写入 fish 使用的 Shell 函数
  2. $XDG_CONFIG_HOME/org.dystroy.broot/launcher/fish/br.fish 软链接到 $HOME/.config/fish/functions/br.fish

首次使用的时候就可以进入到交互式导航 CLI TUI 了:

退出的时候它将会提示说写入了配置文件到 $HOME/.config/broot

shell
 br
New Configuration files written in "/Users/neko/.config/broot".
You should have a look at them: their comments will help you configure broot.
You should especially set up your favourite editor in verbs.hjson.

贡献者

页面历史

撰写

布局切换

调整 VitePress 的布局样式,以适配不同的阅读习惯和屏幕环境。

全部展开
使侧边栏和内容区域占据整个屏幕的全部宽度。
全部展开,但侧边栏宽度可调
侧边栏宽度可调,但内容区域宽度不变,调整后的侧边栏将可以占据整个屏幕的最大宽度。
全部展开,且侧边栏和内容区域宽度均可调
侧边栏宽度可调,但内容区域宽度不变,调整后的侧边栏将可以占据整个屏幕的最大宽度。
原始宽度
原始的 VitePress 默认布局宽度

页面最大宽度

调整 VitePress 布局中页面的宽度,以适配不同的阅读习惯和屏幕环境。

调整页面最大宽度
一个可调整的滑块,用于选择和自定义页面最大宽度。

内容最大宽度

调整 VitePress 布局中内容区域的宽度,以适配不同的阅读习惯和屏幕环境。

调整内容最大宽度
一个可调整的滑块,用于选择和自定义内容最大宽度。

聚光灯

支持在正文中高亮当前鼠标悬停的行和元素,以优化阅读和专注困难的用户的阅读体验。

ON开启
开启聚光灯。
OFF关闭
关闭聚光灯。

聚光灯样式

调整聚光灯的样式。

置于底部
在当前鼠标悬停的元素下方添加一个纯色背景以突出显示当前鼠标悬停的位置。
置于侧边
在当前鼠标悬停的元素旁边添加一条固定的纯色线以突出显示当前鼠标悬停的位置。